export default {
  methods: {
    numberFormatter (value) {
      if (isNaN(value) || value == '' || value == null) return 0.00;
      return `${(parseFloat(value) * 100).toFixed(2)}%`;
    },
    thousandsFormatter (num) {
      let isNegative = Math.sign(num) === -1,
        nums = (isNegative ? Math.abs(num) : num).toString(),
        result = '';
      
      nums = nums.split('.');
      while (nums[0].length > 3) {
        result = ',' + nums[0].slice(-3) + result;
        nums[0] = nums[0].slice(0, nums[0].length - 3);
      }
      if (nums[0]) { result = nums[0] + result };
      if (nums[1]) { result = result + '.' + nums[1] };
      return isNegative ? `-${result}` : result;
    },
    filterArray (arr) {
      let array = [];
      if (arr.length == 0) return array;
      arr.forEach((item) => {
        array.push(item.key);
      });
      return array;
    }
  }
}